home *** CD-ROM | disk | FTP | other *** search
- Path: yarrow.wt.com.au!not-for-mail
- From: brendanl@wt.com.au (Brendan Langoulant)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Message port
- Date: 29 Feb 1996 19:32:31 GMT
- Organization: Winthrop Technology
- Message-ID: <4h4v0f$esk@yarrow.wt.com.au>
- References: <708.6632T987T2426@academy.bastad.se>
- NNTP-Posting-Host: sage
- X-Newsreader: TIN [UNIX 1.3 950520BETA PL0]
-
- Sten Jansson (sten@academy.bastad.se) wrote:
- : I've tried to create a message-port in a simple test-program. It works,
- : ,but as soon as I start another program the message-port disappear.
- : Here is my program:
- : --
- : void AddportT(struct MsgPort * MP)
- : {
- : int SIGBIT;
- :
- : if((SIGBIT=AllocSignal(-1L))==-1)
- : exit(0);
- :
- : MP= AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
-
- You pass a message port to this routine, but it is discarded at this
- point before it is ever used. The value of this message port will not be
- passed back either as you are only modifying a copy of the pointer.
-
- : Please help me if You know what's wrong! Maybe I should use some
- : special compiler directives?
-
- Try this pair of calls, they do everything you want.
-
- struct MsgPort *CreatePort( STRPTR name, long pri );
- void DeletePort( struct MsgPort *ioReq );
-
- eg.
-
- main()
- {
- struct MsgPort *port;
-
- /* Attempt to allocate a port */
- if ( port = CreatePort( "PortName", -125 ) )
- {
-
- /* Clean up Message Port */
- DeletePort( port );
- }
- else
- {
- /* Failed to allocate a port */
- }
- }
-
- --
- Brendan Langoulant
- Software Author
- brendanl@mail.wt.com.au
-